export function computeCenterAndZoom(defaultZoom = 7, lineData = [], allInfo = {}) {
  let zoom = defaultZoom;
  const center = [112.53, 32.99];
  if (lineData.length > 0) {
    const start = lineData[0];
    const end = lineData[lineData.length - 1];
    center[0] = (Number(start.lng) + Number(end.lng)) / 2;
    center[1] = (Number(start.lat) + Number(end.lat)) / 2;
  }
  const { projectTechnicalList = [] } = allInfo || {};
  if (projectTechnicalList && projectTechnicalList.length > 0) {
    let indicatorContent = projectTechnicalList[1].indicatorContent;
    if (indicatorContent.indexOf('km') > -1) {
      indicatorContent = indicatorContent.split('km')[0];
    }
    if (indicatorContent.indexOf('KM') > -1) {
      indicatorContent = indicatorContent.split('KM')[0];
    }
    const length = Number(indicatorContent);
    if (length <= 25) {
      zoom = 15;
    } else if (length <= 50) {
      zoom = 11;
    } else {
      const z = Math.ceil(length / 100);
      zoom = (12 - z) > 4 ? 12 - z-1 : 4;
    }
  }
  return { zoom, center };
};
